package com.innovation.sys.common.config;

import com.innovation.sys.common.constant.SourceParam;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

public class JedisConfig {
	private static JedisPool jedisPool;
	static {
		JedisPoolConfig jedisConfig = new JedisPoolConfig();
		jedisConfig.setMaxTotal(100);
		jedisConfig.setMaxIdle(10);
		jedisConfig.setMaxWaitMillis(100);
		// redis主机名称和端口号
		jedisPool = new JedisPool(jedisConfig, SourceParam.REDIS_HOST, SourceParam.REDIS_PORT, SourceParam.MAX_WAIT,
				SourceParam.REDIS_PASS);
	}

	public static Jedis getJedis() {
		return jedisPool.getResource();
	}

	public static void close(Jedis jedis) {
		jedis.close();
	}

}
